package com.cjm.one.goods.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.cjm.one.goods.mapper.GoodsCommentTagMapper;
import com.cjm.one.goods.service.GoodsCommentTagService;
import com.cjm.one.model.goods.entity.GoodsCommentTag;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
* @author 29289
* @description 针对表【goods_comment_tag】的数据库操作Service实现
* @createDate 2024-11-01 21:14:56
*/
@Service
public class GoodsCommentTagServiceImpl extends ServiceImpl<GoodsCommentTagMapper, GoodsCommentTag>
    implements GoodsCommentTagService {
    @Resource
    private GoodsCommentTagMapper goodsCommentTagMapper;
    @Override
    public Page<GoodsCommentTag> pageList(Long current, Long size,String keyword) {
        LambdaQueryWrapper<GoodsCommentTag> goodsCommentTagLambdaQueryWrapper = new LambdaQueryWrapper<>();
        if (keyword != null) {
            goodsCommentTagLambdaQueryWrapper.like(GoodsCommentTag::getTagName, keyword);
        }
        Page<GoodsCommentTag> page = new Page<>(current, size);
        return goodsCommentTagMapper.selectPage(page,goodsCommentTagLambdaQueryWrapper);
    }

    @Override
    public Boolean saveTag(GoodsCommentTag goodsCommentTag) {
        LambdaQueryWrapper<GoodsCommentTag> goodsCommentTagLambdaQueryWrapper = new LambdaQueryWrapper<>();
        goodsCommentTagLambdaQueryWrapper.eq(GoodsCommentTag::getTagName, goodsCommentTag.getTagName());
        GoodsCommentTag goodsCommentTag1 = goodsCommentTagMapper.selectOne(goodsCommentTagLambdaQueryWrapper);
        if (goodsCommentTag1 == null) {
            return goodsCommentTagMapper.insert(goodsCommentTag) > 0;
        }else {
            return false;
        }

    }
}




